<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON</title>
</head>
<script type="text/javascript">
    var jsonObject = {
        "name": "test",
        "age": 12,
        "address": {"city": "beijing", "school": "collage"},
        "teaching": function () {
            alert("javaEE, Android...");
        }
    };
    alert(jsonObject.name);
    alert(jsonObject.address.city);
    jsonObject.teaching();

    var jsonStr = "{'name':'testname'}";
    //把一个字符串转换为json对象:使用eval方法
    //eval可以把字符串转换为本地的js代码来执行
    var testObj = eval("(" + jsonStr + ")");
    alert(testObj.name);

</script>
<body>

</body>
</html>